//
//  WelcomeViewController.swift
//  XLWB
//
//  Created by 郭亮 on 16/3/16.
//  Copyright © 2016年 gl. All rights reserved.
//

import UIKit
import SDWebImage

class WelcomeViewController: UIViewController {
    @IBOutlet weak var iconView: UIImageView!
    @IBOutlet weak var nameLable: UILabel!
    @IBOutlet weak var iconViewTopCons: NSLayoutConstraint!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //设置图片
        let urlString = UserAccountViewModal.shareInstance.accessToken?.avatar_large ?? ""
        iconView.sd_setImageWithURL(NSURL(string: urlString))
        
        //设置lable
        nameLable.text = UserAccountViewModal.shareInstance.accessToken?.screen_name ?? ""
        nameLable .sizeToFit()
        
        //设置动画
        iconViewTopCons.constant = 100
        UIView .animateWithDuration(2.0, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 10.0, options: [], animations: { () -> Void in
            self.view.layoutIfNeeded()
            }) { (_) -> Void in
               //跳转到首页
                UIApplication.sharedApplication().keyWindow?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
        }
    }
}
